{extend name="layout"/}
{block name='progress'}
<div class="progress active progress-mini">
    <div class="progress-bar progress-bar-info progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 80%"></div>
</div>
{/block}
{block name='content'}
    <div class="box-content step4 text-center">
        <img src="__IMG__/loading.gif" alt="">
        <div id="loading-area">
            <span id="loading-text">0%</span>
            <div id="msg">正在安装...</div>
        </div>
    </div>
    <script type="text/javascript">
        var loading_text = document.getElementById('loading-text');
        var message = document.getElementById('msg');
        function show_progress(msg, status){
            console.log(msg);
            loading_text.innerText = msg;
        }
        function showmsg(msg, status){
            message.innerText = msg;
        }
    </script>
    {php}
        use think\Db;
        // 连接数据库
        $db_config = session('db_config');
        $db_instance = Db::connect($db_config);

        // 创建数据表
        create_tables($db_instance, $db_config['prefix']);

        // 创建配置文件
        $conf = write_config($db_config);

        echo "<script type=\"text/javascript\">location.href='". url('index/complete') ."'</script>";
    {/php}
{/block}